/**
 * 密码策略管理
 * @author liang.xu
 * @date 2021.09.01
 */
var  JQ_PWD_POLICY_FACTORY={
	  "userInfo":null,
	  "customer":null,
	  "init":function(user,customer) {
		  this.userInfo = user;
		  this.customer = customer;
		  var _pwdPolicy=this.getPwdPolicy();
		  $('.pwdTip').html(_pwdPolicy['tip']);
	  },
	 getPwdPolicy:function(){
        var pwdPolicy=this[this.customer];
        if(!pwdPolicy){
        	pwdPolicy=this.default;
		}
        console.info(pwdPolicy);
        return pwdPolicy;
	 },
	 registerPwdPolicy:function(policyKey,func){
	  	this[policyKey]=func;
	 }
}

//注册密码策略 start
//默认密码策略
JQ_PWD_POLICY_FACTORY.registerPwdPolicy("default",{
	"tip":"不少于8位,至少包含大小写英文字母和阿拉伯数字",
	"checkPwd":function(val){
			var reg = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[^]{8,}$/;
			return val.match(reg);
	}
})

//宝马密码策略
JQ_PWD_POLICY_FACTORY.registerPwdPolicy("sysBaoma",{
	"tip":"15到30个字符之间<br>(a-z, A-Z)的字母、数字或以下字符之一的组合:& *:.!# _-<br>不能包含用户id和名称",
	"checkPwd":function(val){
		if(val.length<15||val.length>30){
			return false;
		}
		var p=/^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[&*:.!#_-])[\da-zA-Z&*:.!#_-]{15,}$/;
		//var p=/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[&*:#_-])[^]{15,}$/;
		if(!(p.test(val))){
			return false;
		}
		if(val.indexOf(JQ_PWD_POLICY_FACTORY.userInfo['id'])>0||val.indexOf(JQ_PWD_POLICY_FACTORY.userInfo['loginid'])>0){
			return false;
		}
		return true;
	}
})

//注册密码策略 end

